﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>编辑用户</title>
      <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../css/Jqbox.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery.loadmask.css" rel="stylesheet" type="text/css" />
    <script src="../Js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="../Js/ligerui.min.js" type="text/javascript"></script>
    <script src="../Js/jquery.dialog.js" type="text/javascript"></script>
    <script src="../Js/jquery.loadmask.min.js" type="text/javascript"></script>
    <script src="../Js/json2.js" type="text/javascript"></script>
    <script src="../Js/conmon.js" type="text/javascript"></script>
    <script type="text/javascript">
        var Row = null;
        var pWind = null;
        var pFirst = true;
        $(function () {
            $("#form1").ligerForm();
            pWind = parent.window.parent.window.getWindow();
            Row = (pWind != null ? pWind.$selectRow : null);


            if (Row != null) {
                $("#txtRole").ligerComboBox({ width: 140, slide: false, data: null });

                $.getJSON('../WebServer/EmpManage.ashx?Action=GetTheDepartmentListJson2', { areaid: Row.A_ID, Rnd: Math.random() }, function (data) {
                    $("#txtRole").ligerComboBox().setData(data);
                    $("#txtRole").ligerComboBox().selectValue(Row.J_ID);
                });

                //赋值
                $("#lbName").text(Row.M_NAME);
                $("#lbSex").text(Row.M_SEX == 0 ? "女" : "男")
                $("#txtCode").val(Row.M_CODE);
                $("#txtTel").val(Row.M_PHONE);
                $("#txtDepartment").val(Row.M_DEPAT);
                $("#txtMail").val(Row.M_EMAIL);

                var proData = [{ id: 0, text: '正常' }, { id: 1, text: '屏蔽'}];

                $("#repassword").click(function () {
                    $("body").mask("数据处理中，请稍候......");
                    var pars = { id: Row.M_ID, pwd: '000000' };
                    $.post('../WebServer/MainAdmin.ashx?Action=UpdatePwd', pars, function (data) {
                        $("body").unmask();
                        var rdata = eval("(" + data + ")");
                        if (rdata.IsSuccess == 1) {
                            showAlertOk("修改成功, 用户 [ " + Row.M_NAME + " ]密码已重置为 [000000].");
                        } else {
                            showErrorTip(rdata.Msg);
                        }
                    });
                });

                $("#deleteuser").click(function () {

                    jqConfirm("删除用户将会删除该用户的考试记录,确认删除[" + Row.M_NAME + "] 吗?", "删除用户", function (action) {
                        if (action == "ok") {
                            $("body").mask("数据处理中，请稍候......");
                            var pars = { userid: Row.M_ID };
                            $.post('../WebServer/MainAdmin.ashx?Action=DeleteUser', pars, function (data) {
                                $("body").unmask();
                                var rdata = eval("(" + data + ")");
                                if (rdata.IsSuccess == 1) {
                                    showAlertOk("删除用户[ " + Row.M_NAME + " ] 资料成功.");
                                    if (pWind) pWind.loadGrid();
                                } else {
                                    showErrorTip("删除用户[ " + Row.M_NAME + " ] 资料失败.");
                                }
                            });
                        }
                    });
                });
            }

            //保存
            $("#btnSave").click(function () {
                if (chk()) {
                    if (Row) {
                        Row.M_CODE = $("#txtCode").val();
                        Row.M_PHONE = $("#txtTel").val();
                        Row.M_DEPAT = $("#txtDepartment").val();
                        Row.J_ID = $("#txtRole_val").val();
                        Row.M_STATUS = $("#txtstate_val").val();
                        Row.M_DATE = "";
                        Row.R_DATE = "";

                        var pars = { data: JSON2.stringify(Row) };
                        $("body").mask("数据处理中，请稍候......");
                        $.post('../WebServer/EmpManage.ashx?Action=UpdateItem', pars, function (data) {
                            $("body").unmask();
                            var rdata = eval("(" + data + ")");
                            if (rdata.IsSuccess > 0) {
                                showAlertOk("修改成功.");
                                if (pWind) pWind.loadGrid();
                            } else {
                                if (rdata.IsSuccess == -99) {
                                    showErrorTip("员工资料修改失败.");
                                } else
                                    showErrorTip(rdata.Msg);
                            }
                        });
                    } //end row
                } //end chk
            });
            $("#btnCancel").click(function () { closeRefresh(false, ""); });

        });


        function chk() {
            var err = "";

            if ($.trim($("#txtTel").val()) == "")
                err = "请输入手机号码!";

            else if (!chkMoblie($("#txtTel").val())) {
                err = "手机号码输入不正确"
            }
            if (err != "") {
                showErrorTip(err);

                return false;
            }

            if ($.trim($("#txtRole").val()) == "") {
                err = "请选择职务!";
                showErrorTip(err);
                return false;
            }

            return true;
        }
      
    </script>

     <style type="text/css">
        .edittable td.editcellmessage,.edittable td.editcellverify,.edittable td.editcell{ padding:5px;line-height:25px;}
        .edittable td.editcellmessage{ padding-left:20px;} 
        body { font-size:12px; background:white;}
    </style>
</head>
<body>
<form id="from1" action="">
     <table cellpadding="0" border="0" cellspacing="0" class="edittable">
        <tr>
         <td  class="editcellmessage">用户名:</td>
         <td><label id="lbName"></label></td>
       
         <td  class="editcellmessage">性别:</td>
         <td><label id="lbSex"></label></td>
        </tr>
         <tr>
          <td  class="editcellmessage">工号:</td>
           <td><input id="txtCode" name="txtCode" type="text" ltype="text" /></td>
           <td  class="editcellmessage">电话:</td>
           <td><input id="txtTel" name="txtTel" type="text" ltype="text" /></td>
        </tr>
        <tr>
           <td  class="editcellmessage">工作部门:</td>
           <td><input id="txtDepartment" name="txtDepartment" type="text" ltype="text" /></td>
           <td  class="editcellmessage">职务:</td>
           <td>
                <input id="txtRole" name="txtRole" type="text"  />
                <!--<input id="txtMail" name="txtMail" type="text" ltype="text" />-->
           </td>
        </tr>
        <tr>
            <td colspan="4">
                <a id="repassword" class="l-button" style="width: 80px; float: right; margin-left: 10px; margin-top: 10px;">重置用户密码</a>
                <a id="deleteuser" class="l-button" style="width: 80px; float: right; margin-left: 10px; margin-top: 10px;">删除用资料</a>
            </td>
        </tr>
        <tr><td colspan="4"><br /><br /><br /></td></tr>
   </table>
      <div class="buttonpanel">
             <div style="float:right; margin-right:10px;">
                 <a id="btnSave" class="button" href="javascript:void(0);"><span>保存</span></a>
                 <a id="btnCancel" class="button" href="javascript:void(0);"><span>关闭</span></a>
              </div>
     </div>
   </form>
</body>
</html>
